<template>
    <!--Modal重置密码-->
    <a-modal
        title="状态变更"
        :visible="visible"
        :confirm-loading="confirmLoading"
        @ok="handleOk"
        @cancel="handleCancel"
    >
        <a-form-model ref="ruleForm" :model="form" :rules="rules" class="wrap100">
            <a-form-model-item prop="status" style="width: 100%">
                <a-radio-group v-model="form.status" name="radioGroup" :default-value="1" style="width: 100%">
                    <a-radio :style="radioStyle" :value="0"> 启用 </a-radio>
                    <a-radio :style="radioStyle" :value="4"> 休眠 </a-radio>
                    <a-radio :style="radioStyle" :value="5"> 锁定 </a-radio>
                    <a-radio :style="radioStyle" :value="6"> 禁用 </a-radio>
                    <!-- <a-radio :style="radioStyle" :value="1"> 启用 </a-radio>
                    <a-radio :style="radioStyle" :value="2"> 未审核 </a-radio>
                    <a-radio :style="radioStyle" :value="3"> 驳回 </a-radio>
                    <a-radio :style="radioStyle" :value="4"> 休眠 </a-radio>
                    <a-radio :style="radioStyle" :value="5"> 锁定 </a-radio>
                    <a-radio :style="radioStyle" :value="6"> 禁用 </a-radio>
                    <a-radio :style="radioStyle" :value="7"> 冻结 </a-radio> -->
                </a-radio-group>
            </a-form-model-item>
        </a-form-model>
    </a-modal>
</template>

<script>
import { updateUserStatus } from '@/api/system/system'
export default {
    name: 'modalUpdateStatus',
    components: {},
    props: {
        visible: {
            value: false,
            type: Boolean,
        },
        id: {
            type: String,
            default: '',
        },
    },
    data() {
        return {
            rules: {
                status: [{ required: true, message: '请选择状态', trigger: 'blur' }],
            },
            confirmLoading: false,
            childrenNode: 'jobs',
            form: {
                status: null,
            },
            radioStyle: {
                display: 'block',
                height: '30px',
                lineHeight: '30px',
                background: 'rgba(0,0,0,.05)',
                borderRadius: '4px',
                marginBottom: '5px',
                padding: '0 10px',
                width: '100%',
            },
        }
    },
    created() {},
    methods: {
        /**
         *@desc  table列表密码重置提交
         *@param {}
         */
        handleOk(e) {
            const _this = this
            this.$refs.ruleForm.validate((valid) => {
                if (valid) {
                    let params = {
                        id: _this.id,
                        state: _this.form.status,
                    }
                    console.log(params)
                    _this.confirmLoading = true
                    updateUserStatus(params)
                        .then((res) => {
                            if (res.status === 200) {
                                //状态更改成功
                                _this.$message.info('状态变更成功')
                                _this.handleCancel()
                                _this.confirmLoading = false
                            }
                        })
                        .catch((err) => {
                            //状态更改失败
                            _this.confirmLoading = false
                        })
                } else {
                  this.$message.warning("请填写完所有必填项信息")
                    _this.confirmLoading = false
                    return false
                }
            })
        },
        /**
         *@desc  table列表密码重置取消
         *@param {}
         */
        handleCancel(e) {
            this.$emit('handleCancel', false)
        },
    },
}
</script>

<style>
.wrap100 .ant-form-item .ant-form-item-control-wrapper {
    width: 100%;
}
</style>
